This invention relates to the display on a computer monitor or other video screen of a plurality of graphic images. In particular, this invention relates to a method and apparatus for displaying a composite of the plurality of images in accordance with a desired compositing operation.
Some computers use graphic images in the user interfaces of their operating systems. In addition, many computers are capable of executing programs which produce graphic displays, or which are used to produce and manipulate graphic images as their end product. Graphic images of the type of concern in this invention are made up of pixels. Each pixel is represented within the computer by pixel information or data having a portion indicative of the color level of the pixel, and a portion indicative of the degree of coverage, or opacity, of the pixel.
In an actual color computer system, such as one using an RGB monitor, pixel color level data typically represent the individual levels of red, green, and blue primary color components of the pixel. In a monochromatic system, such data typically represent only the gray level (ranging from white to black) of the pixel. In the discussion which follows, the present invention is explained in an exemplary context of a monochromatic computer system, in which the color level data of each pixel represent the monochromatic gray level of the pixel. It will be appreciated by those skilled in the art, however, that the present invention may also be used in a true color (e.g., RGB) system by applying the disclosed techniques to the individual data representing the color components of the pixel. Thus, as used below, the phrases "color level" and "color component level" are to be understood as meaning either the monochromatic gray level, or the level of a color component, of a pixel.
Pixel color level and opacity data each range from a minimum to a maximum. In a monochromatic system, color (gray) level ranges from white to black, while opacity ranges from transparent to opaque. The precision of the range depends on the number of bits used in the particular computer system to represent the graphic components. In a one-bit graphics monochromatic system, each component of pixel data (gray level and opacity) can assume either of only two values (0 or 1), with no intermediate representation. Thus, in such a system a pixel's gray level could only be white (0) or black (1) with nothing in between, while opacity could only be completely transparent (0) or totally opaque (1). In a two-bit graphics system, the data may assume any of four possible values (00, 01, 10, 11) so that each portion of pixel data can assume two intermediate values representative of shades of gray and degrees of transparency. With additional bits, greater precision is possible.
When two or more graphic images are manipulated on a computer display, it may be desired, as part of the manipulation, to cause one image to overlap or cover the other to produce a composite image. For example, it may be desired to place an image of a person in front of an image of a house, to produce a single composite image of the person standing in front (and obscuring a portion) of the house. Or, it may be desired to place a fully or partially transparent image (e.g., a window) over an opaque image (e.g, a person) to allow the image of the person to show through the window. The resulting composite image will depend on the precise nature of the compositing manipulation, and on the degree of color and opacity of each pair of overlapping pixels.
In T. Porter et al., "Compositing Digital Images", Computer Graphics, vol. 18, no. 3, pp. 253-259 (July 1984), twelve possible compositing operations are described for combining pixel color data and opacity data from two images to produce pixel data for a third composite image. The twelve operations, operating on images A (the source, or first input, image) and B (the destination, or second input or output, image), are:
1. A over B. The image resulting from this operation shows all of A and all of B except that portion of B covered by a portion of A. Stated another way, this operation results in a composite image showing image A wherever A is opaque, and image B elsewhere.
2. B over A. The image resulting from this operation shows all of B and all of A except that portion of A covered by a portion of B. Stated another way, this operation results in a composite image showing image B wherever B is opaque, and image A elsewhere.
3. A in B. The image resulting from this operation shows only that part of A overlapping B, and none of B.
4. B in A. The image resulting from this operation shows only that part of B overlapping A, and none of A.
5. A out B. The image resulting from this operation shows all of A except that part of A overlapping B, and none of B.
6. B out A. The image resulting from this operation shows all of B except that part of B overlapping A, and none of A.
7. A atop B. The image resulting from this operation shows only that part of A overlapping B and that part of B not overlapped by A.
8. B atop A. The image resulting from this operation shows only that part of B overlapping A and that part of A not overlapped by B.
9. A xor B. The image resulting from this operation shows only those parts of A and B not overlapping.
10. Clear. The image resulting from this operation is a clear transparent screen, regardless of the original appearances of A and B.
11. A. The image resulting from this operation is only A.
12. B. The image resulting from this operation is only B.
Porter et al. show a generalized equation, having four operands, for calculating both the color and opacity portions of a composite image of A and B. The data for images A and B are considered to range in value from 0 to 1 for arithmetic purposes, represented by as many bits as the graphics system uses for such purposes. The equation has the form XA+YB, where X and Y are coefficients taught by Porter et al. for each of the twelve operations. The same generalized equation (applying the same coefficients to different pixel data terms) is used for calculating the pixel's color level and opacity components. In a monochromatic system, therefore, the equation is used twice (once for gray level, and once for opacity, data). This requires at least four multiplication steps and two addition steps to composite each pixel. In an RGB color system, the equation is used four times (once each for the red, green, and blue color level data, and once for opacity). This requires at least eight multiplications and four additions. The result is that in a computer system capable of producing high resolution graphics images comprised of hundreds of thousands of pixels, the compositing operation can be slow.
It therefore would be desirable to be able to reduce the computer resources required to perform compositing operations, and thus to enhance the speed of the compositing process.